﻿using System.Linq;
using NUnit.Framework;
using AB.ServiceDirectory.BO;
using AB.ServiceDirectory.Commons.DataFilters;
namespace AB.ServiceDirectory.TestScripts
{
    [TestFixture]
    public class HServiceOrganizationTestBo
    {
        private string _sortType;
        private int _startRowIndex;
        private int _maxRows;

        /// <summary>
        /// Setups this instance.
        /// </summary>
        [SetUp]
        public void Setup()
        {
            _sortType = "OrganisationName";  //sortExpression="Organisation"
            _startRowIndex = 0;  //from rowindex=0
            _maxRows = 15;  //take 15 records
        }

        #region GetServiceOrganizationCount
        /// <summary>
        /// Tests the get service orgnization count1_ input filter_ return row count.
        /// </summary>
        [Test]
        public void TestGetServiceOrgnizationCount1_InputFilter_ReturnRowCount()
        {
            var filter = new HServiceOrganizationFilter();
            filter.ServiceId = 12;
            int rowCount = HServiceOrganizationBO.GetSerivceOrganizationCount(filter);
            Assert.Greater(rowCount,0);
        }

        /// <summary>
        /// Tests the get service orgnization count2_ input filter_ return row count.
        /// </summary>
        [Test]
        public void TestGetServiceOrgnizationCount2_InputFilter_ReturnRowCount()
        {
            var filter = new HServiceOrganizationFilter();
            filter.ServiceId = 000;
            int rowCount = HServiceOrganizationBO.GetSerivceOrganizationCount(filter);
            Assert.AreEqual(rowCount, 0);
        }
        #endregion

        #region GetServiceOrganization
        /// <summary>
        /// Tests the get service organization1_ input filter_ return list of service orgnization.
        /// </summary>
        [Test]

        public void TestGetServiceOrganization1_InputFilter_ReturnListOfServiceOrgnization()
        {
            var filter = new HServiceOrganizationFilter();
            filter.ServiceId = 12;
            var serviceOrgnizations = HServiceOrganizationBO.GetServiceOrganization(filter,_sortType,_startRowIndex,_maxRows);
            Assert.Greater(serviceOrgnizations.Count(),0);
        }

        [Test]
        public void TestGetOrgnization2_InputFilter_ReturnNull()
        {
            var filter = new HServiceOrganizationFilter();
            filter.ServiceId = 000;
            var serviceOrgnizations=HServiceOrganizationBO.GetServiceOrganization(filter,_sortType,_startRowIndex,_maxRows);
            Assert.AreEqual(serviceOrgnizations.Count(),0);
        }
        #endregion

        #region UpdateServiceOrganizationRole

        /// <summary>
        /// Tests the update service organization role1_ input not existed service id as1st parameter not existed organization id as2nd paramater not null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole1_InputNotExistedServiceIdAs1stParameterNotExistedOrganizationIdAs2ndParamaterNotNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 000;//not existed serviceId
            int organizationId = 000; //not existed OrganizationId
            string role = "Auditor";
            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, role);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role2_ input not existed service id as1st parameter not existed organization id as2nd paramater null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole2_InputNotExistedServiceIdAs1stParameterNotExistedOrganizationIdAs2ndParamaterNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 000;//not existed serviceId
            int organizationId = 000; //not existed OrganizationId

            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, null);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role3_ input not existed service id as1st parameter existed organization id as2nd paramater not null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole3_InputNotExistedServiceIdAs1stParameterExistedOrganizationIdAs2ndParamaterNotNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 000;//not existed serviceId
            int organizationId = 17; //existed OrganizationId
            string role = "Auditor";
            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, role);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role4_ input not existed service id as1st parameter existed organization id as2nd paramater null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole4_InputNotExistedServiceIdAs1stParameterExistedOrganizationIdAs2ndParamaterNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 000;//not existed serviceId
            int organizationId = 17; //existed OrganizationId

            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, null);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role5_ input existed service id as1st parameter not existed organization id as2nd paramater not null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole5_InputExistedServiceIdAs1stParameterNotExistedOrganizationIdAs2ndParamaterNotNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 12;//existed serviceId
            int organizationId = 000; //not existed OrganizationId
            string role = "Auditor";
            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, role);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role6_ input not existed service id as1st parameter not existed organization id as2nd paramater null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole6_InputNotExistedServiceIdAs1stParameterNotExistedOrganizationIdAs2ndParamaterNullRoleAs3rdParameter_ReturnFalse()
        {
            int serviceId = 000;//not existed serviceId
            int organizationId = 000; //not existed OrganizationId

            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, null);
            Assert.IsFalse(result);
        }

        /// <summary>
        /// Tests the update service organization role7_ input existed service id as1st parameter existed organization id as2nd paramater not null role as3rd parameter_ return true.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole7_InputExistedServiceIdAs1stParameterExistedOrganizationIdAs2ndParamaterNotNullRoleAs3rdParameter_ReturnTrue()
        {
            int serviceId = 12;//existed serviceId
            int organizationId = 17; //existed OrganizationId
            string role = "Auditor";
            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, role);
            Assert.IsTrue(result);
        }

        /// <summary>
        /// Tests the update service organization role8_ input existed service id as1st parameter existed organization id as2nd paramater null role as3rd parameter_ return false.
        /// </summary>
        [Test]
        public void TestUpdateServiceOrganizationRole8_InputExistedServiceIdAs1stParameterExistedOrganizationIdAs2ndParamaterNullRoleAs3rdParameter_ReturnTrue()
        {
            int serviceId = 12;//existed serviceId
            int organizationId = 17; //existed OrganizationId

            bool result = HServiceOrganizationBO.UpdateServiceOrganizationRole(serviceId, organizationId, null);
            Assert.IsTrue(result);
        }
        #endregion
    }
}
